package com.ttj.controller.purchaser;

import java.io.IOException;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ttj.domain.oracle.WebValidationCode;
import com.ttj.service.WebValidationCodeService;
import com.ttj.vo.BaseRes;

@Controller
@RequestMapping("purchaser/code")
public class WebValidationCodeController {
	
	private static Logger logger = LoggerFactory.getLogger(WebValidationCodeController.class);
	
	@Resource
	private WebValidationCodeService codeService;
	
	@RequestMapping(value="/getVerify",method=RequestMethod.GET)
	public @ResponseBody BaseRes<WebValidationCode> getVerify(String phone,int type) throws IOException{
		logger.debug(phone,type);
		return codeService.buildVerify(phone,type);
	}
	
	@RequestMapping(value="/next",method=RequestMethod.GET)
	public @ResponseBody int upd(String phone,String code){
		logger.debug(code,phone);
		return codeService.upd(phone, code);
	}
	
	@RequestMapping(value="/checkVerify",method=RequestMethod.GET)
	public @ResponseBody BaseRes<WebValidationCode> checkVerify(String phone,String code,int type){
		logger.debug(code,phone,type);
		return codeService.checkVerify(phone,code,type);
	}
}
